﻿using AspNetDemo.App_Start;
using NHibernate;
using NHibernate.Cfg;

namespace AspNetDemo.Services
{
    public class SessionHelper
    {
        private SessionHelper() {
            _congiuration = HibernateConfig.BuildConfig();
            _sessionFactory = _congiuration.BuildSessionFactory();
        }

        private static SessionHelper _instance;
        private static Configuration _congiuration;
        private static ISessionFactory _sessionFactory;

        static SessionHelper()
        {
            _instance = new SessionHelper();
        }

        public static SessionHelper Instance { get { return _instance; } }

        public ISession GetSession()
        {
            return _sessionFactory.OpenSession();
        }
    }
}